package com.google.code.timeeditapplication.model.implementation;

import java.util.GregorianCalendar;
/**
 * A class describing a "lesson" (a lecture/exercise/lab etc).
 * @author deas
 *
 */
public class ScheduleItem implements Comparable<ScheduleItem>{
	private int id;
	private String name, type, location;
	private GregorianCalendar startTime, endTime;
	private boolean visibility;
	
	/**
	 * 
	 * @param id A number to identify a specific ScheduleItem (useful when updating a modified ScheduleItem)
	 * @param name Name of the ScheduleItem
	 * @param type Type of the ScheduleItem (e.g. Lecture, Exercise etc.)
	 * @param location Where the lesson described by the ScheduleItem will take place
	 * @param startTime When the lesson described by the ScheduleItem starts
	 * @param endTime When the lesson described by the ScheduleItem ends
	 */
	public ScheduleItem(int id, String name, String type, String location, GregorianCalendar startTime, GregorianCalendar endTime){
		this.id = id;
		this.name = name;
		this.type = type;
		this.location = location;
		this.startTime = (GregorianCalendar)startTime.clone();
		this.endTime = (GregorianCalendar)endTime.clone();
		this.visibility = true;
	}
	
	/**
	 * 
	 * @param sI The ScheduleItem to clone
	 */
	public ScheduleItem(ScheduleItem sI){
		this.id = sI.id;
		this.name = sI.name;
		this.type = sI.type;
		this.location = sI.location;
		this.startTime = (GregorianCalendar)sI.startTime.clone();
		this.endTime = (GregorianCalendar)sI.endTime.clone();
		this.visibility = sI.visibility;
	}
	
	/**
	 * 
	 * @return Identification number of ScheduleItem
	 */
	public int getId(){
		return this.id;
	}
	
	/**
	 * 
	 * @return Name of ScheduleItem
	 */
	public String getName(){
		return this.name;
	}
	
	/**
	 * 
	 * @return Type of ScheduleItem
	 */
	public String getType(){
		return this.type;
	}
	
	/**
	 * 
	 * @return Location of ScheduleItem
	 */
	public String getLocation(){
		return this.location;
	}
	
	/**
	 * 
	 * @return Starting time of ScheduleItem
	 */
	public GregorianCalendar getStartTime(){
		return (GregorianCalendar)this.startTime.clone();
	}
	
	/**
	 * 
	 * @return Ending time of ScheduleItem
	 */
	public GregorianCalendar getEndTime(){
		return (GregorianCalendar)this.endTime.clone();
	}
	
	/**
	 * 
	 * @return Visibility of ScheduleItem
	 */
	public boolean isVisible(){
		return this.visibility;
	}
	
	/**
	 * 
	 * @param location Set location of ScheduleItem to this
	 */
	public void setLocation(String location){
		this.location = location;
	}
	
	/**
	 * 
	 * @param startTime Set starting time of ScheduleItem to this
	 */
	public void setStartTime(GregorianCalendar startTime){
		this.startTime = (GregorianCalendar)startTime.clone();
	}
	
	/**
	 * 
	 * @param endTime Set ending time of ScheduleItem to this
	 */
	public void setEndTime (GregorianCalendar endTime){
		this.endTime = (GregorianCalendar)endTime.clone();
	}
	
	/**
	 * 
	 * @param visibility Set visibility of ScheduleItem to this
	 */
	public void setVisibility(boolean visibility){
		this.visibility = visibility;
	}
	
	/**
	 * 
	 * @return year when ScheduleItem starts
	 */
	public int getStartYear(){
		return this.startTime.getTime().getYear();
	}
	
	/**
	 * 
	 * @return month of year when ScheduleItem starts
	 */
	public int getStartMonth(){
		return this.startTime.getTime().getMonth();
	}
	
	/**
	 * 
	 * @return day of month when ScheduleItem starts
	 */
	public int getStartDay(){
		return this.startTime.getTime().getDate();
	}
	
	/**
	 * 
	 * @return hour of day when ScheduleItem starts
	 */
	public int getStartHour(){
		return this.startTime.getTime().getHours();
	}
	
	/**
	 * 
	 * @return minute of hour when ScheduleItem starts
	 */
	public int getStartMinute(){
		return this.startTime.getTime().getMinutes();
	}
	
	/**
	 * 
	 * @return year when ScheduleItem ends
	 */
	public int getEndYear(){
		return this.endTime.getTime().getYear();
	}
	
	/**
	 * 
	 * @return month of year when ScheduleItem ends
	 */
	public int getEndMonth(){
		return this.endTime.getTime().getMonth();
	}
	
	/**
	 * 
	 * @return day of month when ScheduleItem ends
	 */
	public int getEndDay(){
		return this.endTime.getTime().getDate();
	}
	
	/**
	 * 
	 * @return hour of day when ScheduleItem ends
	 */
	public int getEndHour(){
		return this.endTime.getTime().getHours();
	}
	
	/**
	 * 
	 * @return minute of hour when ScheduleItem ends
	 */
	public int getEndMinute(){
		return this.endTime.getTime().getMinutes();
	}

	public int compareTo(ScheduleItem si) {
		return this.getStartTime().compareTo(si.getStartTime());
	}
}
